{include file="public/header" /}
<head>

    <link rel="stylesheet" href="__STATIC__/pdf/jquery.touchPDF.css">
    <!-- 新 Bootstrap4 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>

    <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
    <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>

    <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
    <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
    <!-- 预览pdf组件 -->
    <script
            src="https://code.jquery.com/jquery-1.12.4.min.js"
            integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
            crossorigin="anonymous"></script>
    <script src="__STATIC__/pdf/jquery.mousewheel.js"></script>
    <script src="__STATIC__/pdf/jquery.panzoom.js"></script>
    <script src="__STATIC__/pdf/jquery.touchPDF.js"></script>
    <script src="__STATIC__/pdf/jquery.touchSwipe.js"></script>
    <script src="__STATIC__/pdf/pdf.compatibility.js"></script>
    <script src="__STATIC__/pdf/pdf.js"></script>
    <script src="__STATIC__/pdf/pdf.worker.js"></script>
</head>
<body>
{if $type=='pdf'}
<div id="myPDF" class="col-12 bg-dark text-dark">

</div>
{elseif $type=='jpg'}
<img src="{$url}" class="p-3" style="width: 100%;height:auto;margin:auto">
{/if}
<div class="container bg-white">
    <form onsubmit="return false">
        <div class="mt-3">
            {if $state==1}
            <button type="button" onclick="DelFiles()" class="btn btn-danger">删除</button>
            {/if}
            <a href="{$url}" download="外图{$num}的文件.{$type}"><button type="button"  class="btn btn-success">下载</button></a>
            {if $type=='pdf'}
            <button type="button" onclick="window.location.href='{$url}'" class="btn btn-danger">直接打开</button>
            {/if}
        </div>
    </form>
</div>
</body>
<script>
    {if $type=='pdf'}
    $(function() {
        $("#myPDF").pdf({
            source: "{$url}",
            redrawOnWindowResize:true,
            color:'black',
            quality:1
        });
    });
    {/if}
    function DelFiles() {
        $.ajax({
            url:"{:url('index/Blueprint/DelOutDrawingFiles')}",
            type:'post',
            dataType:'json',
            data:{
                id:"{$id}"
            },
            success:function (res) {
                if(res.state==500)
                {
                    layer.msg(res.msg);
                    return;
                }
                if(res.state==200)
                {
                    layer.msg(res.msg, {icon: 1,time: 1000},
                        function () {
                            location.reload();
                        });
                    return;
                }
            }
        })
    }
</script>
</html>